package com.itheima.health.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.health.dao.MemberDao;
import com.itheima.health.pojo.Member;
import com.itheima.health.service.MemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ：seanyang
 * @date ：Created in 2019/6/29
 * @description ：
 * @version: 1.0
 */
@Service
@Slf4j
public class MemberServiceImpl implements MemberService {

	@Autowired
	private MemberDao memberDao;

	@Override
	public Member findByTelephone(String telephone) {
		return memberDao.findByTelephone(telephone);
	}

	@Transactional
	@Override
	public void add(Member member) {
		memberDao.add(member);
	}

	@Override
	public List<Integer> findMemberCountByMonth(List<String> monthList) {
		List<Integer> integerList = new ArrayList<>();
		for (int i = 0;i!=monthList.size();i++){
			integerList.add(memberDao.findMemberCountBeforeDate(monthList.get(i)+".31"));
		}
		return integerList;
	}
}
